//
//  EvaluateViewController.m
//  DianDangDai
//
//  Created by bhf on 2017/12/26.
//  Copyright © 2017年 bhf. All rights reserved.
//

#import "EvaluateViewController.h"
#import "EvaluateCell.h"
@interface EvaluateViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@property (nonatomic, strong) NSArray *array;

@end

@implementation EvaluateViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.array = @[@"pic1.jpg",@"pic2.jpg",@"pic3.jpg",@"pic4.jpg",@"pic5.jpg",@"pic6.jpg"];
    self.title = @"我要评估";
    self.navigationItem.backBarButtonItem = BarButtonItem;
    // Do any additional setup after loading the view.
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 2;
}

- (NSInteger)collectionView:(nonnull UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    if (section == 0) {
        return 6;
    } else {
        return 1;
    }

}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *const ID = @"evaluate_cell";
    EvaluateCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
    if (indexPath.section == 0) {
        cell.image.image = [UIImage imageNamed:_array[indexPath.item]];
        cell.lab.text = @"在线评估";
    } else {
        cell.image.image = [UIImage imageNamed:@"pic7.jpg"];
        cell.lab.text = @"在线评估";
    }
    
    
    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return CGSizeMake((self.collectionView.frame.size.width-30)/2, (self.collectionView.frame.size.height+30)/2.6);
    } else {
        return CGSizeMake((self.collectionView.frame.size.width-20), (self.collectionView.frame.size.height+30)/2.6);
    }
    
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    
    return UIEdgeInsetsMake(0, 10, 10, 10);
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.item == 0) {
        [self showViewControllerWithIdentifier:@"guijinshu"];
    } else if (indexPath.item == 1) {
        [self showViewControllerWithIdentifier:@"dianzi"];
    } else if (indexPath.item == 2) {
        [self showViewControllerWithIdentifier:@"zhubao"];
    }
}

- (void)showViewControllerWithIdentifier:(NSString *) Identifier {
    
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Evaluate" bundle:[NSBundle mainBundle]];
    UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:Identifier];
    viewController.hidesBottomBarWhenPushed = YES;
    
    [self showViewController:viewController sender:self];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
